﻿require([
"jquery",
"ko",
"bootstrap",
"jquery-slimscroll",
"bootstrap-datepicker",
"jquery-select2",
"akcy"], function ($, ko) {
    var akcy = arguments[arguments.length - 1];
    akcy.ui.init();

    var todo = function () {

        // private functions & variables

        var _initComponents = function () {

            // init datepicker
            $('.todo-taskbody-due').datepicker({
                rtl: akcy.ui.isRTL(),
                orientation: "left",
                autoclose: true
            });

            // init tags        
            $(".todo-taskbody-tags").select2({
                tags: ["Testing", "Important", "Info", "Pending", "Completed", "Requested", "Approved"]
            });
        }

        var _handleProjectListMenu = function () {
            if (akcy.ui.getViewPort().width <= 992) {
                $('.todo-project-list-content').addClass("collapse");
            } else {
                $('.todo-project-list-content').removeClass("collapse").css("height", "auto");
            }
        }

        // public functions
        return {

            //main function
            init: function () {
                _initComponents();
                _handleProjectListMenu();

                akcy.ui.addResizeHandler(function () {
                    _handleProjectListMenu();
                });
            }

        };

    }();

    todo.init();
});